package com.woniuxy.oldmanapi.controller;

import com.woniuxy.oldmanapi.service.*;
import com.woniuxy.oldmanapi.vo.PiliangVo;
import com.woniuxy.oldmanapi.vo.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class PiliangController {
    @Autowired
    PiliangService piliangService;

    @PostMapping("/piliang/add")
    public ResponseResult<Void> add(@RequestBody PiliangVo piliangVo) {
        ResponseResult<Void> result = new ResponseResult<>();
        try {
            piliangService.add(piliangVo);
            result.setCode(200);
            result.setMsg("添加成功!");
        } catch (Exception e) {
            e.printStackTrace();
            result.setCode(201);
            result.setMsg("添加失败!");
        }
        return result;
    }
}
